/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * @author  Rezan Achmad
 *          13508104
 * Play.java
 *
 * Created on May 7, 2010, 7:50:57 PM
 */

package View.PlayMode;

import Model.Building.Barrack;
import Model.Building.Blacksmith;
import Model.Building.Building;
import Model.Building.BuildingContainer;
import Model.Building.Castle;
import Model.Character.CharacterContainer;
import Model.Character.Constanta;
import Model.Character.Job.Job;
import Model.Character.Race.Race;
import Model.Character.Special.Special;
import Model.Game;
import Model.Map.Map;
import Support.Converter;
import Support.IOObject;
import Support.ImageSupport;
import Support.Path;
import View.MainMenu;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GraphicsDevice;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Vector;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.plaf.basic.BasicBorders.FieldBorder;

/**
 *
 * @author user
 */
public class Play extends javax.swing.JFrame implements MouseListener{

    /** 
     * Creates new form Play
     */
    public Play(MainMenu parent, GraphicsDevice device, Map map, Vector<Integer> vrace, Game game) {
        super(device.getDefaultConfiguration());
        JPanel j = new JPanel();
        this.device = device;
        this.parent = parent; /* Pointed parent Window */
        this.map = map; /* init map */
        this.game = game;
        initComponents();
        ShowWindow();
        InitMap();
        setFocusable(true);

        /* show player turn & it's gold */
        playerTurnLabel.setText("Player "+game.getPlayerturn()+" Turn. Your Gold is "+game.getGold(game.getPlayerturn())+".");

        /* inisiate list character */
        fillListCharacter();
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        playerComboBox = new javax.swing.JComboBox();
        layerpane = new javax.swing.JLayeredPane();
        scrollPane = new javax.swing.JScrollPane();
        mapLayerPane = new javax.swing.JLayeredPane();
        terrainPanel = new javax.swing.JPanel();
        buildingPanel = new javax.swing.JPanel();
        warnaPanel = new javax.swing.JPanel();
        karakterPanel = new javax.swing.JPanel();
        selectedPanel = new javax.swing.JPanel();
        menuPanel = new javax.swing.JPanel();
        saveButton = new javax.swing.JButton();
        closeButton = new javax.swing.JButton();
        listCharacterPanel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        listcharacterTextArea = new javax.swing.JTextArea();
        characterPanel = new javax.swing.JPanel();
        attackButton = new javax.swing.JButton();
        moveButton = new javax.swing.JButton();
        specialButton = new javax.swing.JButton();
        waitButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();
        upgradecharacterPanel = new javax.swing.JPanel();
        upgradejobButton = new javax.swing.JButton();
        upgradestatusButton = new javax.swing.JButton();
        buildingactionPanel = new javax.swing.JPanel();
        summonCharacterButton = new javax.swing.JButton();
        upgradeBuldingButton = new javax.swing.JButton();
        playerPanel = new javax.swing.JPanel();
        surrenderButton = new javax.swing.JButton();
        endTurnButton = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        infoTextArea = new javax.swing.JTextArea();
        buildPanel = new javax.swing.JPanel();
        barrackButton = new javax.swing.JButton();
        blackSmithButton = new javax.swing.JButton();
        listButton = new javax.swing.JButton();
        ListCharacterPanel = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        listTextArea = new javax.swing.JTextArea();
        listCharacterLabel = new javax.swing.JLabel();
        nextButton = new javax.swing.JButton();
        prevButton = new javax.swing.JButton();
        infoPanel = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        infoTextarea = new javax.swing.JTextArea();
        playerTurnLabel = new javax.swing.JLabel();
        listJobPanel = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        listJob = new javax.swing.JList();
        selectJobButton = new javax.swing.JButton();
        listSpecialPanel = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        listSpecial = new javax.swing.JList();
        selectSpecialButton = new javax.swing.JButton();

        playerComboBox.setFont(new java.awt.Font("Tahoma", 0, 18));
        playerComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        playerComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                playerComboBoxActionPerformed(evt);
            }
        });

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Dunno");
        setAlwaysOnTop(true);
        setResizable(false);
        setUndecorated(true);
        addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                formMouseMoved(evt);
            }
        });
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            }
        });

        layerpane.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        mapLayerPane.setBackground(new java.awt.Color(0, 0, 0));
        mapLayerPane.setOpaque(true);

        terrainPanel.setOpaque(false);
        terrainPanel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                terrainPanelMousePressed(evt);
            }
        });

        javax.swing.GroupLayout terrainPanelLayout = new javax.swing.GroupLayout(terrainPanel);
        terrainPanel.setLayout(terrainPanelLayout);
        terrainPanelLayout.setHorizontalGroup(
            terrainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        terrainPanelLayout.setVerticalGroup(
            terrainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        terrainPanel.setBounds(30, 80, -1, -1);
        mapLayerPane.add(terrainPanel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        buildingPanel.setOpaque(false);

        javax.swing.GroupLayout buildingPanelLayout = new javax.swing.GroupLayout(buildingPanel);
        buildingPanel.setLayout(buildingPanelLayout);
        buildingPanelLayout.setHorizontalGroup(
            buildingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        buildingPanelLayout.setVerticalGroup(
            buildingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        buildingPanel.setBounds(280, 80, -1, -1);
        mapLayerPane.add(buildingPanel, new Integer(2));

        warnaPanel.setOpaque(false);

        javax.swing.GroupLayout warnaPanelLayout = new javax.swing.GroupLayout(warnaPanel);
        warnaPanel.setLayout(warnaPanelLayout);
        warnaPanelLayout.setHorizontalGroup(
            warnaPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        warnaPanelLayout.setVerticalGroup(
            warnaPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        warnaPanel.setBounds(150, 80, -1, -1);
        mapLayerPane.add(warnaPanel, new Integer(1));

        karakterPanel.setOpaque(false);

        javax.swing.GroupLayout karakterPanelLayout = new javax.swing.GroupLayout(karakterPanel);
        karakterPanel.setLayout(karakterPanelLayout);
        karakterPanelLayout.setHorizontalGroup(
            karakterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        karakterPanelLayout.setVerticalGroup(
            karakterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        karakterPanel.setBounds(420, 80, -1, -1);
        mapLayerPane.add(karakterPanel, new Integer(3));

        selectedPanel.setOpaque(false);
        selectedPanel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                selectedPanelMousePressed(evt);
            }
        });

        javax.swing.GroupLayout selectedPanelLayout = new javax.swing.GroupLayout(selectedPanel);
        selectedPanel.setLayout(selectedPanelLayout);
        selectedPanelLayout.setHorizontalGroup(
            selectedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        selectedPanelLayout.setVerticalGroup(
            selectedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        selectedPanel.setBounds(580, 80, -1, -1);
        mapLayerPane.add(selectedPanel, new Integer(7));

        scrollPane.setViewportView(mapLayerPane);

        scrollPane.setBounds(20, 120, 520, 140);
        layerpane.add(scrollPane, javax.swing.JLayeredPane.DEFAULT_LAYER);

        menuPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Menu", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N
        menuPanel.setOpaque(false);
        menuPanel.setLayout(null);

        saveButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        saveButton.setText("Save Game");
        saveButton.setFocusable(false);
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });
        menuPanel.add(saveButton);
        saveButton.setBounds(5, 15, 100, 25);

        closeButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        closeButton.setText("Close");
        closeButton.setFocusable(false);
        closeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeButtonActionPerformed(evt);
            }
        });
        menuPanel.add(closeButton);
        closeButton.setBounds(105, 15, 100, 25);

        menuPanel.setBounds(790, 270, 210, 45);
        layerpane.add(menuPanel, new Integer(1));

        listCharacterPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("List Character"));
        listCharacterPanel.setOpaque(false);
        listCharacterPanel.setLayout(null);

        listcharacterTextArea.setColumns(12);
        listcharacterTextArea.setFont(new java.awt.Font("Monospaced", 0, 12));
        listcharacterTextArea.setRows(5);
        jScrollPane1.setViewportView(listcharacterTextArea);

        listCharacterPanel.add(jScrollPane1);
        jScrollPane1.setBounds(20, 40, 168, 120);

        listCharacterPanel.setBounds(740, 20, 200, -1);
        layerpane.add(listCharacterPanel, new Integer(1));

        characterPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Character Action", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N
        characterPanel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        characterPanel.setOpaque(false);
        characterPanel.setPreferredSize(new java.awt.Dimension(110, 135));
        characterPanel.setLayout(null);

        attackButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        attackButton.setText("Attack");
        attackButton.setAlignmentY(0.0F);
        attackButton.setFocusable(false);
        attackButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                attackButtonActionPerformed(evt);
            }
        });
        characterPanel.add(attackButton);
        attackButton.setBounds(5, 15, 100, 25);

        moveButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        moveButton.setText("Move");
        moveButton.setAlignmentY(0.0F);
        moveButton.setFocusable(false);
        moveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                moveButtonActionPerformed(evt);
            }
        });
        characterPanel.add(moveButton);
        moveButton.setBounds(5, 40, 100, 25);

        specialButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        specialButton.setText("Special");
        specialButton.setToolTipText("Special 1 lho");
        specialButton.setAlignmentY(0.0F);
        specialButton.setFocusable(false);
        specialButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                specialButtonActionPerformed(evt);
            }
        });
        characterPanel.add(specialButton);
        specialButton.setBounds(105, 15, 100, 25);

        waitButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        waitButton.setText("Wait");
        waitButton.setAlignmentY(0.0F);
        waitButton.setFocusable(false);
        waitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                waitButtonActionPerformed(evt);
            }
        });
        characterPanel.add(waitButton);
        waitButton.setBounds(105, 40, 100, 25);

        cancelButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        cancelButton.setText("Cancel");
        cancelButton.setAlignmentY(0.0F);
        cancelButton.setFocusable(false);
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });
        characterPanel.add(cancelButton);
        cancelButton.setBounds(205, 15, 100, 25);

        characterPanel.setBounds(590, 370, 310, 70);
        layerpane.add(characterPanel, new Integer(1));

        upgradecharacterPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Upgrade Character", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N
        upgradecharacterPanel.setOpaque(false);
        upgradecharacterPanel.setLayout(null);

        upgradejobButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        upgradejobButton.setText("Upgrade Job");
        upgradejobButton.setFocusable(false);
        upgradejobButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                upgradejobButtonActionPerformed(evt);
            }
        });
        upgradecharacterPanel.add(upgradejobButton);
        upgradejobButton.setBounds(5, 15, 150, 25);

        upgradestatusButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        upgradestatusButton.setText("Upgrade Status");
        upgradestatusButton.setFocusable(false);
        upgradestatusButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                upgradestatusButtonActionPerformed(evt);
            }
        });
        upgradecharacterPanel.add(upgradestatusButton);
        upgradestatusButton.setBounds(5, 40, 150, 25);

        upgradecharacterPanel.setBounds(840, 90, 160, 70);
        layerpane.add(upgradecharacterPanel, new Integer(1));

        buildingactionPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Building", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N
        buildingactionPanel.setOpaque(false);
        buildingactionPanel.setLayout(null);

        summonCharacterButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        summonCharacterButton.setText("Summon Character");
        summonCharacterButton.setFocusable(false);
        summonCharacterButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                summonCharacterButtonMousePressed(evt);
            }
        });
        buildingactionPanel.add(summonCharacterButton);
        summonCharacterButton.setBounds(5, 15, 150, 25);

        upgradeBuldingButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        upgradeBuldingButton.setText("Upgrade Building");
        upgradeBuldingButton.setFocusable(false);
        upgradeBuldingButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                upgradeBuldingButtonActionPerformed(evt);
            }
        });
        buildingactionPanel.add(upgradeBuldingButton);
        upgradeBuldingButton.setBounds(5, 40, 150, 25);

        buildingactionPanel.setBounds(1030, 580, 160, 70);
        layerpane.add(buildingactionPanel, new Integer(1));

        playerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Player", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N
        playerPanel.setMinimumSize(new java.awt.Dimension(160, 60));
        playerPanel.setOpaque(false);
        playerPanel.setLayout(null);

        surrenderButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        surrenderButton.setText("Surrender");
        surrenderButton.setFocusable(false);
        playerPanel.add(surrenderButton);
        surrenderButton.setBounds(5, 40, 150, 25);

        endTurnButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        endTurnButton.setText("End Turn");
        endTurnButton.setFocusable(false);
        endTurnButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                endTurnButtonMousePressed(evt);
            }
        });
        playerPanel.add(endTurnButton);
        endTurnButton.setBounds(5, 15, 150, 25);

        playerPanel.setBounds(840, 180, 160, 70);
        layerpane.add(playerPanel, new Integer(1));

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Info"));
        jPanel2.setLayout(null);

        infoTextArea.setColumns(20);
        infoTextArea.setRows(5);
        jScrollPane2.setViewportView(infoTextArea);

        jPanel2.add(jScrollPane2);
        jScrollPane2.setBounds(6, 31, 166, 180);

        jPanel2.setBounds(100, 340, -1, -1);
        layerpane.add(jPanel2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        buildPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Build", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N
        buildPanel.setOpaque(false);
        buildPanel.setPreferredSize(new java.awt.Dimension(160, 70));
        buildPanel.setLayout(null);

        barrackButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        barrackButton.setText("Barrack");
        barrackButton.setFocusable(false);
        barrackButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                barrackButtonMousePressed(evt);
            }
        });
        buildPanel.add(barrackButton);
        barrackButton.setBounds(5, 15, 150, 25);

        blackSmithButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        blackSmithButton.setText("BlackSmith");
        blackSmithButton.setFocusable(false);
        blackSmithButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                blackSmithButtonMousePressed(evt);
            }
        });
        buildPanel.add(blackSmithButton);
        blackSmithButton.setBounds(5, 40, 150, 25);

        buildPanel.setBounds(1030, 470, 160, 70);
        layerpane.add(buildPanel, new Integer(1));

        listButton.setFont(new java.awt.Font("Tahoma", 0, 12));
        listButton.setText("List Character");
        listButton.setFocusable(false);
        listButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listButtonActionPerformed(evt);
            }
        });
        listButton.setBounds(860, 40, 125, 25);
        layerpane.add(listButton, new Integer(1));

        ListCharacterPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "List Character", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N
        ListCharacterPanel.setOpaque(false);
        ListCharacterPanel.setLayout(null);

        listTextArea.setColumns(20);
        listTextArea.setFont(new java.awt.Font("Monospaced", 0, 12));
        listTextArea.setRows(5);
        jScrollPane3.setViewportView(listTextArea);

        ListCharacterPanel.add(jScrollPane3);
        jScrollPane3.setBounds(10, 50, 180, 220);

        listCharacterLabel.setFont(new java.awt.Font("Tahoma", 0, 12));
        listCharacterLabel.setForeground(new java.awt.Color(255, 255, 255));
        listCharacterLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        listCharacterLabel.setText("Player");
        ListCharacterPanel.add(listCharacterLabel);
        listCharacterLabel.setBounds(65, 25, 70, 14);

        nextButton.setText(">");
        nextButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextButtonActionPerformed(evt);
            }
        });
        ListCharacterPanel.add(nextButton);
        nextButton.setBounds(140, 20, 50, 25);

        prevButton.setText("<");
        prevButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                prevButtonActionPerformed(evt);
            }
        });
        ListCharacterPanel.add(prevButton);
        prevButton.setBounds(10, 20, 50, 25);

        ListCharacterPanel.setBounds(1020, 20, 200, 280);
        layerpane.add(ListCharacterPanel, new Integer(1));

        infoPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Info", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N
        infoPanel.setOpaque(false);
        infoPanel.setLayout(null);

        infoTextarea.setColumns(20);
        infoTextarea.setFont(new java.awt.Font("Monospaced", 0, 12));
        infoTextarea.setRows(5);
        jScrollPane4.setViewportView(infoTextarea);

        infoPanel.add(jScrollPane4);
        jScrollPane4.setBounds(10, 20, 180, 250);

        infoPanel.setBounds(70, 290, 200, 280);
        layerpane.add(infoPanel, new Integer(1));

        playerTurnLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
        playerTurnLabel.setForeground(new java.awt.Color(255, 255, 255));
        playerTurnLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        playerTurnLabel.setText("Player Turn 1. Your Gold 1234");
        playerTurnLabel.setBounds(350, 340, 220, 30);
        layerpane.add(playerTurnLabel, new Integer(1));

        listJobPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "List Job", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N
        listJobPanel.setOpaque(false);
        listJobPanel.setLayout(null);

        listJob.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane5.setViewportView(listJob);

        listJobPanel.add(jScrollPane5);
        jScrollPane5.setBounds(10, 20, 130, 120);

        selectJobButton.setText("Select Job");
        selectJobButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                selectJobButtonActionPerformed(evt);
            }
        });
        listJobPanel.add(selectJobButton);
        selectJobButton.setBounds(10, 145, 130, 25);

        listJobPanel.setBounds(540, 460, 150, 180);
        layerpane.add(listJobPanel, new Integer(1));

        listSpecialPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "List Special", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N
        listSpecialPanel.setOpaque(false);
        listSpecialPanel.setLayout(null);

        listSpecial.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane6.setViewportView(listSpecial);

        listSpecialPanel.add(jScrollPane6);
        jScrollPane6.setBounds(10, 20, 130, 120);

        selectSpecialButton.setText("Select Special");
        selectSpecialButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                selectSpecialButtonActionPerformed(evt);
            }
        });
        listSpecialPanel.add(selectSpecialButton);
        selectSpecialButton.setBounds(10, 145, 130, 25);

        listSpecialPanel.setBounds(350, 430, 150, 180);
        layerpane.add(listSpecialPanel, new Integer(1));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(layerpane, javax.swing.GroupLayout.PREFERRED_SIZE, 1256, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(22, Short.MAX_VALUE)
                .addComponent(layerpane, javax.swing.GroupLayout.PREFERRED_SIZE, 695, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void playerComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_playerComboBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_playerComboBoxActionPerformed

    private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed
        int key = evt.getKeyCode();
        if (key == KeyEvent.VK_S) {
            Integer n =scrollPane.getVerticalScrollBar().getValue();
            n = n + 5;
            scrollPane.getVerticalScrollBar().setValue(n);
        }

        if (key == KeyEvent.VK_W) {
            Integer n =scrollPane.getVerticalScrollBar().getValue();
            n = n - 5;
            scrollPane.getVerticalScrollBar().setValue(n);
        }

        if (key == KeyEvent.VK_A) {
            Integer n =scrollPane.getHorizontalScrollBar().getValue();
            n = n - 5;
            scrollPane.getHorizontalScrollBar().setValue(n);
        }

        if (key == KeyEvent.VK_D) {
            Integer n =scrollPane.getHorizontalScrollBar().getValue();
            n = n + 5;
            scrollPane.getHorizontalScrollBar().setValue(n);
        }
    }//GEN-LAST:event_formKeyPressed

    private void formMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseMoved
        if (evt.getX()<5) {
            int n = scrollPane.getHorizontalScrollBar().getValue();
            n = n - 5;
            scrollPane.getHorizontalScrollBar().setValue(n);
            //JOptionPane.showMessageDialog(this, evt);
        }

        if (evt.getX()>1275) {
            int n = scrollPane.getHorizontalScrollBar().getValue();
            n = n + 5;
            scrollPane.getHorizontalScrollBar().setValue(n);
        }

        if (evt.getY()<5) {
            int n = scrollPane.getVerticalScrollBar().getValue();
            n = n - 5;
            scrollPane.getVerticalScrollBar().setValue(n);
            //JOptionPane.showMessageDialog(this, evt);
        }

         if (evt.getY()>795) {
            int n = scrollPane.getVerticalScrollBar().getValue();
            n = n + 5;
            scrollPane.getVerticalScrollBar().setValue(n);
        }
    }//GEN-LAST:event_formMouseMoved

    private void blackSmithButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_blackSmithButtonMousePressed
        /* Check selected grid -> can't build if there is no grid selected */
        if (selectedterrain==null)
            return;

        /* Check Money -> can't build if no enaugh money */
        if (game.getGold(game.getPlayerturn()) < Building.BLACKSMITH_COST) {
            JOptionPane.showMessageDialog(this, "Uang Anda Tidak Cukup.");
            return;
        }

        /* Check terrain -> can't build on water and mud */
        Point p = selectedterrain.getLocation();
        Point pGrid = Converter.PointToGrid(p);
        int t = game.getMap().GetTerrain(pGrid.x, pGrid.y);
        if (t == Map.AIR || t == Map.LUMPUR || t == Map.POHON)
            return;

        /* Check Building -> can't build if there is a building */
        Building b = game.getMap().GetBuilding(pGrid.x, pGrid.y);
        if (b!=null)
            return;

        /* Check character -> can't build if there is a character*/
        Model.Character.Character c = game.getCharacters().get(pGrid.x, pGrid.y);
        if (c!=null)
            return;

        int turn = game.getPlayerturn();
        game.setGold(turn, game.getGold(turn)-Building.BLACKSMITH_COST);
        updateTurnInformation();
        game.getMap().SetBuilding(Map.BLACKSMITH, game.getPlayerturn(), pGrid.x, pGrid.y, 0, 0);
        InitMap();
}//GEN-LAST:event_blackSmithButtonMousePressed

    private void barrackButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_barrackButtonMousePressed
        /* Check selected grid -> can't build if there is no grid selected */
        if (selectedterrain==null)
            return;

        /* Check Money -> can't build if no enaugh money */
        if (game.getGold(game.getPlayerturn()) < Building.BARRACK_COST) {
            JOptionPane.showMessageDialog(this, "Uang Anda Tidak Cukup.");
            return;
        }

        /* Check terrain -> can't build on water and mud */
        Point p = selectedterrain.getLocation();
        Point pGrid = Converter.PointToGrid(p);
        int t = game.getMap().GetTerrain(pGrid.x, pGrid.y);
        if (t == Map.AIR || t == Map.LUMPUR)
            return;

        /* Check Building -> can't build if there is a building */
        Building b = game.getMap().GetBuilding(pGrid.x, pGrid.y);
        if (b!=null)
            return;

        /* Check character -> can't build if there is a character*/
        Model.Character.Character c = game.getCharacters().get(pGrid.x, pGrid.y);
        if (c!=null)
            return;

        int turn = game.getPlayerturn();
        game.setGold(turn, game.getGold(turn)-Building.BARRACK_COST);
        updateTurnInformation();

        /* get character */
        CharacterContainer cc =game.getCharacters();
        for (int i=0;i<cc.size();++i) {
            c = cc.get(i);
            if (c.getPlayer()==turn)
                break;
        }

        /* build */
        double[] factor = c.GetAtribut().getRaceChar().GetFactorBuilding();
        game.getMap().SetBuilding(Map.BARRACK, game.getPlayerturn(), pGrid.x, pGrid.y, factor[1], factor[0]);
        InitMap();
}//GEN-LAST:event_barrackButtonMousePressed

    private void endTurnButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_endTurnButtonMousePressed
        int n= game.getPlayerturn();
        updateGold(n);
        n%=game.getMap().GetNumPlayer();
        ++n;
        game.setPlayerturn(n);

        /* decrease building time */
        BuildingContainer bc = game.getMap().GetBuildings();
        Building b;
        for (int i=0;i<bc.size();++i) {
            b = bc.get(i);
            if (b.getBuilding_BaseAtribut(b.BUILDING_PLAYER_IDX)==n) {
                b.DecreaseBuildingBuildTime();
            }
        }

        /* decrease buff & enable all character */
        CharacterContainer cc = game.getCharacters();
        Model.Character.Character c;
        for (int i=0;i<cc.size();++i) {
            c = cc.get(i);
            if (c.getPlayer()==n) {
                c.ReduceBuffDuration();
                c.setEnable(true);
                c.setAttack(false);
                c.setMove(false);
            }
        }
        
        playerTurnLabel.setText("Player "+n+" Turn. Your Gold is "+game.getGold(n)+".");
}//GEN-LAST:event_endTurnButtonMousePressed

    private void updateGold(int player) {
        BuildingContainer bc = game.getMap().GetBuildings();
        Building b;
        int gold = 0;
        for (int i=0;i<bc.size();++i) {
            b = bc.get(i);
            if (b.getBuilding_BaseAtribut(b.BUILDING_PLAYER_IDX)==player) {
                gold += b.getBuilding_BaseAtribut(b.BUILDING_GOLD_PER_TURN_IDX);
                //bugArea.setText("tambah gold player :"+player+" gold : "+gold);
            }
        }
        game.setGold(player, game.getGold(player)+gold);
    }

    private void summonCharacterButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_summonCharacterButtonMousePressed
        /* check if barrack is selected */
        Point p = selectedBuildingLabel .getLocation();
        Point pGrid = Converter.PointToGrid(p);
        int x = pGrid.x;
        int y = pGrid.y;

        Building b = game.getMap().GetBuilding(x, y);
        if (!(b instanceof Barrack))
            return;

        /* Character is on building? -> can't summon if there is character on barrack */
        Model.Character.Character c= game.getCharacters().get(x, y);
        if (c!=null) {
            JOptionPane.showMessageDialog(this, "Masih ada karakter diatas barrack.");
            return;
        }

        /* get cost summon */
        int cost = Constanta.PRICE_SUMMON_NOVICE;

        /* show information */
        int ans = JOptionPane.showConfirmDialog(this, "Harga "+cost+". Akan melakukan summon?", "Konfirmasi", JOptionPane.YES_NO_OPTION);
            if (ans==JOptionPane.NO_OPTION) {
                return;
            }

        /* check money */
            if (game.getGold(game.getPlayerturn()) < cost ) {
                JOptionPane.showMessageDialog(this, "Uang tidak cukup.");
                return;
            }

        int player = game.getPlayerturn();
        int RaceID = game.getVrace().get(player-1);
        c = new Model.Character.Character(RaceID, player);
        c.setLocation(x, y);
        game.getCharactermap()[x][y] = c.getID();
        game.getCharacters().add(c);
        c.setEnable(false);

        InitMap();
}//GEN-LAST:event_summonCharacterButtonMousePressed

    private void upgradejobButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_upgradejobButtonActionPerformed
        boolean visible = listJobPanel.isVisible();
        listJobPanel.setVisible(!visible);
        
        JLabel l=selectedcharLabel;
        Point p = l.getLocation();
        Point pGrid = Converter.PointToGrid(p);
        int x = pGrid.x;
        int y = pGrid.y;
        String s;
        Model.Character.Character c = game.getCharacters().get(x, y);

        Vector<Integer> vlistjob = c.getNextJob();
        DefaultListModel listmodel = new DefaultListModel();
        Integer jobid = null;
        s = new String();
        for (int i=0;i<vlistjob.size();++i) {
            jobid = vlistjob.get(i);
            listmodel.addElement(Job.GetJobNameByID(jobid));
            s += Job.GetJobNameByID(jobid);
            s += "\n";
        }
        //bugArea.setText(s);
        listJob.setModel(listmodel);
        
//        c.JobChange(2);
//        s = Integer.toString(c.GetAtribut().GetRaceID());
//        s += Integer.toString(2);
//        l.setIcon(ImageSupport.createImageIcon(s+".png", null));
}//GEN-LAST:event_upgradejobButtonActionPerformed

    private void moveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveButtonActionPerformed
        int width = game.getMap().GetWidth();
        int height = game.getMap().GetHeight();
        MapArea = new int[width][height];
        boolean[][] MapBuilding;
        boolean[][] MapPlayer;
        Path p = new Path();
        Model.Character.Character c = selectedChar;

        /* init mapBuilding (contain true & false)*/
        MapBuilding = new boolean[width][height];
        for (int i=0;i<width;++i) {
            for (int j=0;j<height;++j) {
                MapBuilding[i][j] = true;
            }
        }
        
        BuildingContainer bc = game.getMap().GetBuildings();
        Building b;
        for (int i=0;i<bc.size();++i) {
            b = bc.get(i);
            if (b.getBuilding_BaseAtribut(b.BUILDING_PLAYER_IDX)!=c.getPlayer()) {
                MapBuilding[b.getBuilding_BaseAtribut(b.BUILDING_X_IDX)][b.getBuilding_BaseAtribut(b.BUILDING_Y_IDX)] = false;
            }
        }

        /* init mapPlayer (contain true & false )*/
        MapPlayer = new boolean[width][height];
        for (int i=0;i<width;++i) {
            for (int j=0;j<height;++j) {
                MapPlayer[i][j] = true;
            }
        }
        CharacterContainer cc = game.getCharacters();
        Model.Character.Character c1;
        for (int i=0;i<cc.size();++i) {
            c1 = cc.get(i);
            if (c1.getPlayer()!=c.getPlayer()) {
                MapPlayer[c1.getX()][c1.getY()]=false;
            }
        }
        
        MapArea = p.SetAreaMove(c.GetAtribut().GetRangeMove(), c.GetAtribut().GetRaceID(), c.getLocation(), game.getMap().getTerrain(), MapBuilding, MapPlayer);
//        String s = new String();
//        for(int i=0;i<width;++i){
//            for (int j=0;j<height;++j){
//                s += MapArea[i][j]+" ";
//            }
//            s += "\n";
//        }
//        System.out.print(s);
        createAreaColor(MapArea);
        move = true;
        
//        Model.Character.Character c;
//        Point p = Converter.PointToGrid(selectedcharLabel.getX(), selectedcharLabel.getY());
//        c = game.getCharacters().get(p.x, p.y);
//        game.getCharactermap()[p.x][p.y] = 0;
//        p.y++;
//        c.Move(p.x, p.y);
//        game.getCharactermap()[p.x][p.y] = c.getID();
//        p = Converter.GridToPoint(p);
//        Thread t = new Thread(new Runnable() {
//            public void run() {
//                Point p = selectedcharLabel.getLocation();
//                for (int i=1;i<=50;++i) {
//                    selectedcharLabel.setLocation(p.x, p.y+i);
//                    try{
//                        Thread.sleep(20);
//                    } catch (InterruptedException e){
//
//                    }
//                }
//            }
//        });
//        t.start();
    }//GEN-LAST:event_moveButtonActionPerformed

    private void updateTurnInformation() {
        playerTurnLabel.setText("Player "+game.getPlayerturn()+" Turn. Your Gold is "+game.getGold(game.getPlayerturn())+".");
    }

    private void createAreaColor(int[][] mapArea) {
        Point p;
        JLabel l;
        for (int i=0;i<mapArea.length;++i) {
            for (int j=0;j<mapArea[0].length;++j) {
                if (mapArea[i][j]<99) {
                    p = Converter.GridToPoint(i, j);
                    l = new JLabel();
                    warnaPanel.add(l);
                    l.setBounds(p.x, p.y, ImageSupport.IMAGE_WIDTH, ImageSupport.IMAGE_HEIGHT);
                    l.setBorder(new FieldBorder(Color.BLUE, Color.BLUE, Color.BLUE, Color.BLUE));
                }
            }
        }
        warnaPanel.repaint();
    }

    private void clearAreaColor(){
        warnaPanel.removeAll();
        warnaPanel.repaint();
    }

    private void listButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listButtonActionPerformed
        list = !list;
        ListCharacterPanel.setVisible(list);
}//GEN-LAST:event_listButtonActionPerformed

    private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
        parent.setVisible(true);
        this.dispose();
}//GEN-LAST:event_closeButtonActionPerformed

    private void terrainPanelMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_terrainPanelMousePressed
        Component c = terrainPanel.getComponentAt(evt.getX(), evt.getY());
        JLabel l;

        disableAllActionPanel();
        if (c instanceof JLabel) {
            if (selectedterrain!=null) {
            selectedterrain.setBorder(null);
            }
            l = (JLabel) c;
            selectedterrain = l;
            l.setBorder(new FieldBorder(Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK));
            infoTextarea.setText("terrain");
        } else {
            return;
        }
    }//GEN-LAST:event_terrainPanelMousePressed

    @SuppressWarnings("static-access")
    private void selectedPanelMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_selectedPanelMousePressed
        int x = evt.getX();
        int y = evt.getY();
        Point p = Converter.PointToGrid(x, y);
        Point pPoint  = Converter.GridToPoint(p);
        selectedLabel.setLocation(pPoint.x, pPoint.y);

        if (move) {
            int n = JOptionPane.showConfirmDialog(null, "Are You Sure?", null, JOptionPane.YES_NO_OPTION);
            if (n == JOptionPane.NO_OPTION)
                return;

            /* check if selectd grid is in area move */
            if (MapArea[p.x][p.y]==99) {
                JOptionPane.showMessageDialog(this, "Move diluar Area");
                return;
            }
            selectedChar.Move(p.x, p.y);

            /* *************** Animasi ************* */
                        

            selectedcharLabel.setLocation(pPoint.x, pPoint.y);

            move = false;
            clearAreaColor();
            updateEnableCharacterButton();
            return;
        }

        /* Attack */
        if(attack){
            int nAttack = JOptionPane.showConfirmDialog(null, "Are You Sure?", null, JOptionPane.YES_NO_OPTION);
            if (nAttack == JOptionPane.NO_OPTION){
                return;
            } else
            if (MapArea[p.x][p.y]==99) {
                JOptionPane.showMessageDialog(this, "Attack di luar jangkauan.");
                return;
            }
            BuildingContainer BuildCont = game.getMap().GetBuildings();
            CharacterContainer CharCont = game.getCharacters();
            Model.Character.Character Char = CharCont.get(p.x, p.y);
            Building Build = BuildCont.get(p.x, p.y);
            if(Char !=null){
                // serang karakter
                if(selectedChar.getPlayer()==Char.getPlayer()){
                    JOptionPane.showMessageDialog(this, "Tidak bisa menyerang teman.");
                    return;
                } else {
                    selectedChar.AttackPlayer(selectedChar, Char);
                    JOptionPane.showMessageDialog(this, "Target karakter telah diserang.");

                    /* check jika karakter yang diserang telah mati */
                    if (Char.GetAtribut().GetCurrent(Constanta.HP_ID) < 1) {
                        /* hapus karakter pada maplogic karakter */
                        game.getCharactermap()[p.x][p.y] = 0;

                        /* hapus karakter pada map */
                        Component c = karakterPanel.getComponentAt(evt.getX(), evt.getY());
                        karakterPanel.remove(c);
                        karakterPanel.repaint();

                        /* hapus karakter dari kontainer */
                        game.getCharacters().remove(Char);

                        /* beri informasi */
                        // JOptionPane.showMessageDialog(this, "Karakter yang Anda serang telah mati.");
                    }
                }
            } else if(Build!=null){
                // serang building
                if(selectedChar.getPlayer()==Build.getBuilding_BaseAtribut(Build.BUILDING_PLAYER_IDX)){
                    JOptionPane.showMessageDialog(this, "Tidak bisa menyerang bangunan sendiri.");
                    return;
                } else {
                    selectedChar.AttackBuilding(selectedChar, Build);
                    JOptionPane.showMessageDialog(this, "Target telah diserang.");

                    /* check jika bangunan yang diserang telah hancur */
                    if (Build.getBuilding_BaseAtribut(Build.BUILDING_HP_IDX)<1) {
                        /* hapus building dari maplogic dan kontainer */
                        game.getMap().eraseBuilding(p.x, p.y);

                        /* hapus building dari buildingpanel */
                        Component c = buildingPanel.getComponentAt(evt.getX(), evt.getY());
                        buildingPanel.remove(c);
                        buildingPanel.repaint();

                    }
                }
            } else {
                // serang lainnya
                if(map.GetTerrain(p.x, p.y)==map.POHON){
                    selectedChar.AttackTree(p.x, p.y);
                    map.SetTerrain(p.x, p.y, map.RUMPUT);

                    /* Change icon label to rumput */
                    Component c = terrainPanel.getComponentAt(evt.getX(), evt.getY());
                    if (c==null) {
                        JOptionPane.showMessageDialog(this, "Pesan bug : Component tidak ditemukan.");
                        return;
                    }

                    if (!(c instanceof JLabel)) {
                        JOptionPane.showMessageDialog(this, "Pesan bug : Component Bukan label.");
                        return;
                    }

                    JLabel l = (JLabel)c;
                    String s = Map.GetString(map.GetTerrain(p.x, p.y));
                    l.setIcon(ImageSupport.createImageIcon(s+".png", null));
                    JOptionPane.showMessageDialog(this, "Pohon berhasil di tebang.");
                } else {
                    JOptionPane.showMessageDialog(this, "Tidak ada target.");
                    return;
                }
            }
            attack = false;
            clearAreaColor();
            updateEnableCharacterButton();
            return;
        }

        Model.Character.Character c = game.getCharacters().get(p.x, p.y);
        if (c!=null) {
            selectedChar = c;
            selectedcharLabel = (JLabel)karakterPanel.getComponentAt(pPoint.x, pPoint.y);
            selectedcharLabel.getMouseListeners()[0].mousePressed(evt);
            return;
        }

        Building b = game.getMap().GetBuildings().get(p.x, p.y);
        if (b!=null) {
            selectedBuilding = b;
            selectedBuildingLabel = (JLabel)buildingPanel.getComponentAt(pPoint.x, pPoint.y);
            selectedBuildingLabel.getMouseListeners()[0].mousePressed(evt);
            return;
        }

        /* terrain */
        selectedterrain = (JLabel)terrainPanel.getComponentAt(x, y);
        String s = Map.GetString(game.getMap().GetTerrain(p.x, p.y));
        infoTextarea.setText(s);
        disableAllActionPanel();
    }//GEN-LAST:event_selectedPanelMousePressed

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        String s = JOptionPane.showInputDialog(this, "Nama File : ", "Save Game", JOptionPane.QUESTION_MESSAGE);
        IOObject.Save(game, s+".game");
    }//GEN-LAST:event_saveButtonActionPerformed

    private void specialButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_specialButtonActionPerformed
        boolean visible = listSpecialPanel.isVisible();
        if (!visible) {
            int i=0;
            Special s = selectedChar.GetSpecial(i);
            DefaultListModel listmodel = new DefaultListModel();
            while (s!=null) {
                listmodel.addElement(s.GetSpecialName());
                ++i;
                s = selectedChar.GetSpecial(i);
            }
            listSpecial.setModel(listmodel);
        }
        listSpecialPanel.setVisible(!visible);
    }//GEN-LAST:event_specialButtonActionPerformed

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        move = false;
        attack = false;
        clearAreaColor();
    }//GEN-LAST:event_cancelButtonActionPerformed

    private void upgradestatusButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_upgradestatusButtonActionPerformed
        /* Check selectedcharacter */
        if (selectedChar==null) {
            JOptionPane.showMessageDialog(this, "Tidak ada karakter yang dipilih.");
            return;
        }

        /* check karakter level */
        int level = selectedChar.GetAtribut().GetRaceLevel();
        if (level>=4) {
            JOptionPane.showMessageDialog(this, "Karakter telah berada pada level maksimal.");
            return;
        }

        /* get upgrade cost */
        int cost = 0;
        if (level == 1) {
            cost = Model.Character.Constanta.PRICE_UPGRADE_STATUS_2;
        } else if (level == 2){
            cost = Model.Character.Constanta.PRICE_UPGRADE_STATUS_3;
        } else if (level == 3) {
            cost = Model.Character.Constanta.PRICE_UPGRADE_STATUS_4;
        }

        /* show information */
        int ans = JOptionPane.showConfirmDialog(this, "Upgrade membutuhkan uang sebesar "+cost, "Upgrade Cost", JOptionPane.YES_NO_OPTION);
        if (ans == JOptionPane.NO_OPTION)
            return;

       /* check money */
        int player = game.getPlayerturn();
        if (game.getGold(player)<cost) {
            JOptionPane.showMessageDialog(this, "Uang Tidak Cukup");
            return;
        }

        /* upgrade karakter atrribut */
        selectedChar.UpgradeCharAtribut();

        /* decrease gold */
        game.setGold(player, game.getGold(player)-cost);

        /* update player turn info */
        updateTurnInformation();

        /* show success message */
        ++level;
        JOptionPane.showMessageDialog(this, "Karakter berhasil diupgrade ke level"+level);
    }//GEN-LAST:event_upgradestatusButtonActionPerformed

    private void upgradeBuldingButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_upgradeBuldingButtonActionPerformed
        /* check selected building */
        if (selectedBuilding==null) {
            JOptionPane.showMessageDialog(this, "Tidak ada bangunan yang dipilih.");
            return;
        }

        /* check building level */
        int level = selectedBuilding.getBuilding_BaseAtribut(Building.BUILDING_LEVEL_IDX);
        if (level==4) {
            JOptionPane.showMessageDialog(this, "Level bangunan telah maksimum.");
            return;
        }

        /* get upgrade cost */
        int cost = selectedBuilding.getUpgradeCost();

        /* show information */
        int ans = JOptionPane.showConfirmDialog(this, "Upgrade membutuhkan uang sebesar "+cost, "Upgrade Cost", JOptionPane.YES_NO_OPTION);
        if (ans == JOptionPane.NO_OPTION)
            return;

       /* check money */
        int player = game.getPlayerturn();
        if (game.getGold(player)<cost) {
            JOptionPane.showMessageDialog(this, "Uang Tidak Cukup");
            return;
        }

        /* upgrade karakter atrribut */
        selectedBuilding.UpgradeBuilding();

        /* decrease gold */
        game.setGold(player, game.getGold(player)-cost);

        /* update player turn info */
        updateTurnInformation();

        /* show success message */
        ++level;
        JOptionPane.showMessageDialog(this, "Bangunan berhasil diupgrade ke level"+level);
    }//GEN-LAST:event_upgradeBuldingButtonActionPerformed

    private void attackButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_attackButtonActionPerformed
        int width = game.getMap().GetWidth();
        int height = game.getMap().GetHeight();
        MapArea = new int[width][height];
        Path p = new Path();
        Model.Character.Character c = selectedChar;
        MapArea = p.SetAreaAttack(c.getLocation(), c.GetAtribut().GetCurrent(Constanta.RANGE_ATTACK_ID), width, height);
        createAreaColor(MapArea);
        attack = true;
    }//GEN-LAST:event_attackButtonActionPerformed

    private void selectJobButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectJobButtonActionPerformed
        int i = listJob.getSelectedIndex();

        /* get upgrade cost */
        int cost = 0 ;
        int level = selectedChar.GetAtribut().GetJobClass();
        if (level == 1) {
            cost = Constanta.PRICE_UPGRADE_JOB2;
        } else if (level == 2) {
            cost = Constanta.PRICE_UPGRADE_JOB3;
        }
        
        if (i>=0) {
            /* show information */
            int ans = JOptionPane.showConfirmDialog(this, "Harga "+cost+". Akan melakukan upgrade?", "Konfirmasi", JOptionPane.YES_NO_OPTION);
            if (ans==JOptionPane.NO_OPTION) {
                return;
            }

            /* check money */
            if (game.getGold(game.getPlayerturn()) < cost ) {
                JOptionPane.showMessageDialog(this, "Uang tidak cukup.");
                return;
            }
            int nextjob = selectedChar.getNextJob().get(i);
            String s;
            selectedChar.JobChange(nextjob);
            s = Integer.toString(selectedChar.GetAtribut().GetRaceID());
            s += Integer.toString(nextjob);
            selectedcharLabel.setIcon(ImageSupport.createImageIcon(s+".png", null));
            listJobPanel.setVisible(false);
        }
    }//GEN-LAST:event_selectJobButtonActionPerformed

    private void waitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_waitButtonActionPerformed
        if (selectedChar!=null) {
            selectedChar.WaitFunction();
            updateEnableCharacterButton();
            disableAllActionPanel();
        }
    }//GEN-LAST:event_waitButtonActionPerformed

    private void selectSpecialButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectSpecialButtonActionPerformed
        
    }//GEN-LAST:event_selectSpecialButtonActionPerformed

    private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextButtonActionPerformed
        if (listcharacterPlayer<game.getMap().GetNumPlayer()) {
            ++listcharacterPlayer;
            fillListCharacter();
        }
    }//GEN-LAST:event_nextButtonActionPerformed

    private void fillListCharacter() {
        String s = new String();
        int n = listcharacterPlayer;
        CharacterContainer cc = game.getCharacters();
        Model.Character.Character c;
        for (int i=0;i<cc.size();++i) {
            c = cc.get(i);
            if (c.getPlayer()==n) {
                /* ID */
                s += "ID : ";
                s += c.getID();
                s += "\n";

                /* JOB */
                s += "Job : ";
                s += Job.GetJobNameByID(c.GetAtribut().GetJobID());
                s += "\n";

                /* RACE */
                s += "Race : ";
                s += Race.getRaceName(c.GetAtribut().GetRaceID());
                s += "\n";

                /* HP */
                s += "HP : ";
                s += c.GetAtribut().GetCurrent(Constanta.HP_ID);
                s += "\n";

                /* SP */
                s += "SP : ";
                s += c.GetAtribut().GetCurrent(Constanta.SP_ID);
                s += "\n\n";
            }
        }

        listTextArea.setText(s);
        listCharacterLabel.setText("Player "+n);
    }

    private void prevButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prevButtonActionPerformed
        if (listcharacterPlayer>1) {
            --listcharacterPlayer;
            fillListCharacter();
        }
    }//GEN-LAST:event_prevButtonActionPerformed

    public void createContent(int x, int y, int width, int height, String iconName, JPanel p) {
        Component c =  p.getComponentAt(x, y);
        if (c!=null) {
            p.remove(c);
        }
        JLabel label;
        label = new JLabel(ImageSupport.createImageIcon(iconName+".png", null));
        label.setBounds(x, y, width, height);
        p.add(label);
        if (p == karakterPanel) {
            label.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent e) {
                    disableAllActionPanel();
                    JLabel l = selectedcharLabel;
                    int x = l.getX();
                    int y = l.getY();
                    Point p = Converter.PointToGrid(x, y);
                    Model.Character.Character c = game.getCharacters().get(p.x, p.y);
                    infoTextarea.setText(c.toString());
                    if (c.getPlayer() == game.getPlayerturn() && c.GetEnable()) {
                        characterPanel.setVisible(true);
                        if (game.getMap().GetBuildings().IsBlackSmithIn(game.getPlayerturn()))
                            upgradecharacterPanel.setVisible(true);
                        selectedChar = c;
                        updateEnableCharacterButton();
                    }
                }
            });
        }

        if (p == buildingPanel) {
            label.addMouseListener(new MouseAdapter() {
                @Override
                public void mousePressed(MouseEvent e) {
                    disableAllActionPanel();
                    summonCharacterButton.setVisible(false);
                    JLabel l = selectedBuildingLabel;
                    int x = l.getX();
                    int y = l.getY();
                    Point p = Converter.PointToGrid(x, y);
                    Building b = game.getMap().GetBuildings().get(p.x, p.y);
                    infoTextarea.setText(b.toString());
                    if (b.getBuilding_BaseAtribut(Building.BUILDING_PLAYER_IDX)==game.getPlayerturn()) {
                        buildingactionPanel.setVisible(true);
                        upgradeBuldingButton.setVisible(true);
                        selectedBuilding = b;

                        if (b instanceof Barrack) {
                            summonCharacterButton.setVisible(true);
                        }

                        if (b.getBuilding_BaseAtribut(b.BUILDING_BUILD_TIME_IDX)>0) {
                            summonCharacterButton.setVisible(false);
                            upgradeBuldingButton.setVisible(false);
                        }
                    }
                }

            });
        }
    }

    private void updateEnableCharacterButton() {
        moveButton.setEnabled(true);
        attackButton.setEnabled(true);
        specialButton.setEnabled(true);
        cancelButton.setEnabled(true);

        if (selectedChar!=null) {
            if (selectedChar.isMove()) {
                moveButton.setEnabled(false);
            }

            if (selectedChar.isAttack()) {
                moveButton.setEnabled(false);
                attackButton.setEnabled(false);
                specialButton.setEnabled(false);
                cancelButton.setEnabled(false);
            }

            characterPanel.repaint();
        }
    }

    /**
     * Tes
     */
    private void InitMap() {
        /* Add new component(terrain & building ) in content Panel */
        int x,y,width,height;
        String image;
        String s =  new String();
        Building b;
        Model.Character.Character c;
        for (int i=0;i<map.GetWidth();++i) {
            for (int j=0;j<map.GetHeight();++j) {
                x = i*ImageSupport.IMAGE_WIDTH;
                y = j*ImageSupport.IMAGE_HEIGHT;
                width = ImageSupport.IMAGE_WIDTH;
                height = ImageSupport.IMAGE_HEIGHT;

                /* paint terrain */
                image = Map.GetString(map.GetTerrain(i, j));
                createContent(x, y, width, height, image, terrainPanel);

                /* paint building */
                b = map.GetBuilding(i, j);
                if (b!=null) {
                    if (b instanceof Castle) {
                        s = Building.CASTLE_S;
                    } else if (b instanceof Barrack) {
                        s = Building.BARRACK_S;
                    } else if (b instanceof Blacksmith) {
                        s = Building.BLACKSMITH_S;
                    }
                    s+=Integer.toString(b.getBuilding_BaseAtribut(b.BUILDING_PLAYER_IDX));
                    createContent(x, y, width, height, s, buildingPanel);
                }

                /* paint character */
                c = game.getCharacters().get(i, j);
                if (c!=null) {
                    s = Integer.toString(c.GetAtribut().GetRaceID());
                    s += Integer.toString(c.GetAtribut().GetJobID());
                    createContent(x, y, width, height, s, karakterPanel);
                }
            }
        }
        terrainPanel.repaint();
        buildingPanel.repaint();
        karakterPanel.repaint();

        /* Set new Size for contentPanel */
        Dimension d = new Dimension(ImageSupport.IMAGE_WIDTH*map.GetWidth(), ImageSupport.IMAGE_HEIGHT*map.GetHeight());
        terrainPanel.setBounds(500, 500, d.width, d.height);
        buildingPanel.setBounds(500, 500, d.width, d.height);
        karakterPanel.setBounds(500, 500, d.width, d.height);
        warnaPanel.setBounds(500, 500, d.width, d.height);
        selectedPanel.setBounds(500, 500, d.width, d.height);
        d.setSize(d.width+1000, d.height+1000);
        mapLayerPane.setPreferredSize(d);
//        mapLayerPane.repaint();
//        scrollPane.setViewportView(mapLayerPane);
    }


    /**
     * Show FullScreen Window
     */
    private void ShowWindow()
    {
        Container pane = getContentPane();
        int x, y, width, height;
        int border = BORDER_MAIN_LAYER_PANE;
        
        boolean isFullScreen;
        isFullScreen = device.isFullScreenSupported();
        //setUndecorated(isFullScreen);
        setResizable(!isFullScreen);

//        if (isFullScreen) {
//            /* Full-screen mode */
//            device.setFullScreenWindow(this);
//            validate();
//        } else {
//            /* Windowed mode */
//            pack();
//            setVisible(true);
//        }
        width = device.getDisplayMode().getWidth();
        height = device.getDisplayMode().getHeight();
        setBounds(0, 0, width, height);
        setVisible(true);

        pane.setBackground(Color.BLACK);

        /* add layerpane to Frame */
        pane.removeAll();
        pane.setLayout(null);
        pane.add(layerpane);
        layerpane.setBounds(border, border, getWidth()-(2*border)-(getInsets().left+getInsets().right), getHeight()-(2*border)-(getInsets().top+getInsets().bottom));

        /* set layerpane's layout to null */
        layerpane.setLayout(null);

        /* set bounds  scrollpane */
        x = 0;
        y = menuPanel.getHeight();
        width = layerpane.getWidth();
        height = layerpane.getHeight()-y-playerPanel.getHeight();
        scrollPane.setBounds(0, y, width, height);

        /* set bounds menuPanel */
        width = menuPanel.getWidth();
        height = menuPanel.getHeight();
        menuPanel.setBounds(0, 0, width, height);

        /* set bounds listPlayePanel */
        width = listCharacterPanel.getPreferredSize().width;
        height = listCharacterPanel.getPreferredSize().height;
        x = layerpane.getWidth()-width;
        y = 0;
        listCharacterPanel.setBounds(x, y, width, height);

        /* set bounds info_and_mainPanel */
//        width = infoPanel.getPreferredSize().width;
//        height = infoPanel.getPreferredSize().height;
//        x = 0;
//        y = layerpane.getHeight()-height;
//        infoPanel.setBounds(x, y, width, height);

        /* set bounds playerPanel */
        width = playerPanel.getWidth();
        height = playerPanel.getHeight();
        x = 0;
        y = layerpane.getHeight()-height;
        playerPanel.setBounds(x, y, width, height);

        /* set bound buildPanel */
        width = buildPanel.getWidth();
        height = buildPanel.getHeight();
        x = playerPanel.getX()+playerPanel.getWidth();
        y = layerpane.getHeight()-height;
        buildPanel.setBounds(x, y, width, height);

        /* set bounds characterpanel */
        width = characterPanel.getWidth();
        height = characterPanel.getHeight();
        x = layerpane.getWidth()- width;
        y = layerpane.getHeight() - height;
        characterPanel.setBounds(x, y, width, height);

        /* set bounds updgradecharacterpanel */
        width = upgradecharacterPanel.getWidth();
        height = upgradecharacterPanel.getHeight();
        x = characterPanel.getX() - width;
        y = layerpane.getHeight() - height;
        upgradecharacterPanel.setBounds(x, y, width, height);

        /* set bounds buildingactionPanel */
        width = buildingactionPanel.getWidth();
        height = buildingactionPanel.getHeight();
        x = buildPanel.getX()+buildPanel.getWidth();
        y = layerpane.getHeight() - height;
        buildingactionPanel.setBounds(x, y, width, height);

        /* scroll */
        scrollPane.setBackground(Color.black);
        scrollPane.setOpaque(false);
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
        scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

        /* list character button */
        width = listButton.getWidth();
        height = listButton.getHeight();
        x = layerpane.getWidth() - width;
        y = scrollPane.getY() - height;
        listButton.setLocation(x, y);

        /* list character panel */
        width = ListCharacterPanel.getWidth();
        height = ListCharacterPanel.getHeight();
        x = scrollPane.getX() + scrollPane.getWidth() - width;
        y = scrollPane.getY();
        ListCharacterPanel.setBounds(x, y, width, height);

        /* info panel */
        width = infoPanel.getWidth();
        height = infoPanel.getHeight();
        x = scrollPane.getX();
        y = scrollPane.getY() + scrollPane.getHeight() - height;
        infoPanel.setBounds(x, y, width, height);

        /* playerTurnLabel */
        width = playerTurnLabel.getWidth();
        height = playerTurnLabel.getHeight();
        x = scrollPane.getX() + (scrollPane.getWidth()/2) - (playerTurnLabel.getWidth()/2);
        y = scrollPane.getY() - playerTurnLabel.getHeight();
        playerTurnLabel.setBounds(x, y, width, height);

        /* selectedLabel */
        selectedLabel = new JLabel();
        selectedPanel.add(selectedLabel);
        selectedLabel.setBounds(0, 0, ImageSupport.IMAGE_WIDTH, ImageSupport.IMAGE_HEIGHT);
        selectedLabel.setBorder(new FieldBorder(Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK));


        /* set bounds list job */
        width = listJobPanel.getWidth();
        height = listJobPanel.getHeight();
        x = upgradecharacterPanel.getX();
        y = upgradecharacterPanel.getY() - height;
        listJobPanel.setBounds(x, y, width, height);
        listJobPanel.setVisible(false);

        /* set bounds list special */
        width = listSpecialPanel.getWidth();
        height = listSpecialPanel.getHeight();
        x = characterPanel.getX() + specialButton.getX();
        y = characterPanel.getY() - height;
        listSpecialPanel.setBounds(x, y, width, height);
        listSpecialPanel.setVisible(false);

        /* barrack and blacksmith Button */
        barrackButton.setToolTipText("Cost : "+Building.BARRACK_COST);
        blackSmithButton.setToolTipText("Cost : "+Building.BLACKSMITH_COST);

        disableAllActionPanel();
    }

    private void disableAllActionPanel(){
        characterPanel.setVisible(false);
        upgradecharacterPanel.setVisible(false);
        buildingactionPanel.setVisible(false);
        listJobPanel.setVisible(false);
        listSpecialPanel.setVisible(false);
    }

    public void mouseClicked(MouseEvent e) {}

    public void mouseEntered(MouseEvent e) {}

    public void mouseExited(MouseEvent e) {}

    public void mousePressed(MouseEvent e) {}

    public void mouseReleased(MouseEvent e) {}
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel ListCharacterPanel;
    private javax.swing.JButton attackButton;
    private javax.swing.JButton barrackButton;
    private javax.swing.JButton blackSmithButton;
    private javax.swing.JPanel buildPanel;
    private javax.swing.JPanel buildingPanel;
    private javax.swing.JPanel buildingactionPanel;
    private javax.swing.JButton cancelButton;
    private javax.swing.JPanel characterPanel;
    private javax.swing.JButton closeButton;
    private javax.swing.JButton endTurnButton;
    private javax.swing.JPanel infoPanel;
    private javax.swing.JTextArea infoTextArea;
    private javax.swing.JTextArea infoTextarea;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JPanel karakterPanel;
    private javax.swing.JLayeredPane layerpane;
    private javax.swing.JButton listButton;
    private javax.swing.JLabel listCharacterLabel;
    private javax.swing.JPanel listCharacterPanel;
    private javax.swing.JList listJob;
    private javax.swing.JPanel listJobPanel;
    private javax.swing.JList listSpecial;
    private javax.swing.JPanel listSpecialPanel;
    private javax.swing.JTextArea listTextArea;
    private javax.swing.JTextArea listcharacterTextArea;
    private javax.swing.JLayeredPane mapLayerPane;
    private javax.swing.JPanel menuPanel;
    private javax.swing.JButton moveButton;
    private javax.swing.JButton nextButton;
    private javax.swing.JComboBox playerComboBox;
    private javax.swing.JPanel playerPanel;
    private javax.swing.JLabel playerTurnLabel;
    private javax.swing.JButton prevButton;
    private javax.swing.JButton saveButton;
    private javax.swing.JScrollPane scrollPane;
    private javax.swing.JButton selectJobButton;
    private javax.swing.JButton selectSpecialButton;
    private javax.swing.JPanel selectedPanel;
    private javax.swing.JButton specialButton;
    private javax.swing.JButton summonCharacterButton;
    private javax.swing.JButton surrenderButton;
    private javax.swing.JPanel terrainPanel;
    private javax.swing.JButton upgradeBuldingButton;
    private javax.swing.JPanel upgradecharacterPanel;
    private javax.swing.JButton upgradejobButton;
    private javax.swing.JButton upgradestatusButton;
    private javax.swing.JButton waitButton;
    private javax.swing.JPanel warnaPanel;
    // End of variables declaration//GEN-END:variables
    private GraphicsDevice device;
    private MainMenu parent;
    public static final int BORDER_MAIN_LAYER_PANE = 50;
    private boolean list = true;
    private Map map;
    private Game game;
    private JLabel selectedterrain;
    private JLabel selectedcharLabel;
    private JLabel selectedBuildingLabel;
    private JLabel borderLabel;
    private JLabel selectedLabel;
    private Model.Character.Character selectedChar;
    private Building selectedBuilding;
    private boolean move = false;
    private boolean attack = false;
    private int[][] MapArea;
    private int listcharacterPlayer = 1;
}
